package com.blueseaapps.utility;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPreferenceManager {
	public static final String PREF_KEY_REGISTRATION_ID="c2dm_regId";
	public static final String LAST_REGISTRATION_CHANGE = "last_registration_change";
	public static final String BACKOFF = "backoff";
	public static final String PREF_KEY_UNIQUE_ID="unique_id";
	
	private static final String PREFERENCE = "com.blueseaapps.photoquiz";
	private static SharedPreferences preferences;
	
	public static String getPreferenceValue(Context cxt, String prefKey){
		preferences = cxt.getSharedPreferences(PREFERENCE, Context.MODE_PRIVATE);
		return preferences.getString(prefKey, null);
	}
	
	public static boolean setPreferenceValue(Context cxt, String prefKey, String value){
		preferences = cxt.getSharedPreferences(PREFERENCE, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putString(prefKey, value);
		return editor.commit();
	}
	
	public static long getPreferenceValueLong(Context cxt, String prefKey){
		preferences = cxt.getSharedPreferences(PREFERENCE, Context.MODE_PRIVATE);
		return preferences.getLong(prefKey, -1);
	}
	
	public static boolean setPreferenceValueLong(Context cxt, String prefKey, long value){
		preferences = cxt.getSharedPreferences(PREFERENCE, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putLong(prefKey, value);
		return editor.commit();
	}

}
